<template>
	<view class="page">
		<search :placeholder="'请输入车牌号查询'" @input="inputChange" :showScreen="true" @goScreen="goScreen"></search>
		
		<screenData @dataChange="screenChange"></screenData>

		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<!-- :down="downOption" :up="upOption" -->

			<uni-list>

				<view class="item" @click="goDetail(item)" v-for="(item, index) in listdata" :key="item.carNo">

					<view style="display: inline-flex; justify-content: flex-end;">

						<text class="title">
							车牌号：{{item.carNo}}
						</text>

						<view class="btn-detail" style="color: #FFC000;background-color:#FFFFFF">
							{{item.illegalStatusShow}}
						</view>
					</view>



					<u-line color="#efefef" :customStyle="{'margin-bottom': '30rpx','display': 'block',}"></u-line>

					<view class="text-line">
						<text class="text-name">车架号:</text>
						<text class="text-value">{{item.vinNo|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">品牌/车系/车型:</text>
						<text class="text-value">{{item.brandName|filterNull}}/{{item.seriesName|filterNull}}/{{item.modelName|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">车辆状态:</text>
						<text class="text-value">{{item.carStatusShow|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name"
							style="color: #E93131;">{{"待处理违章" + item.count + "条/扣" + item.pointsDeduction + "分/罚款" + item.illegalFines + "元"}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">更新时间:</text>
						<text class="text-value">{{item.updateTime|filterNull}}</text>
					</view>


					<view style="display: inline-flex; justify-content: flex-end;">
						<view class="btn-detail">
							详 情
						</view>
					</view>


				</view>
			</uni-list>

		</mescroll-body>


	</view>
</template>

<script>
	import search from '../../components/search.vue';
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import screenData from "@/components/screen-data.vue"

	export default {
		mixins: [MescrollMixin],
		components: {
			search,
			screenData
		},
		data() {
			return {
				page: 1,
				listdata: [],
				searchWord: "",
				sData:{}
			}
		},
		
		onUnload() {
			console.log('--------执行清除---------');
			uni.$emit('clearAll', true);
		},
		
		methods: {
			getData() {

				this.$u.api.illegalList({
						...this.sData,
						searchVal: this.searchWord,
						pageNo: this.page,
					}).then(
						res => {
							// if (res.code == 1) {
							if (this.page == 1) {

                this.listdata = [];
              }
              this.listdata = this.listdata.concat(res);
              this.mescroll.endSuccess(res.length);
              // }
						}
					)
					.catch(() => {
						this.mescroll.endErr();
					})
			},
			
			goScreen(){
				console.log('跳转筛选');
				uni.navigateTo({
					url: '/pagesB/screen/screen?type=TrafficViolation'
				})
			},
			
			screenChange(res){
				
				console.log('=页面最终收到筛选变动了=res====', res);
				
				this.sData = res;
				
				this.page = 1;
				this.getData();
				
			},

			goDetail(item) {
				uni.navigateTo({
					url: './illegaldetail?carNo=' + item.carNo + "&carCode=" + item.carCode,
				})
			},

			upCallback(page) {
				console.log("触发了上拉加载" + page);

				this.page = page.num;
				this.getData();
			},

			inputChange(value) {
				this.searchWord = value;
				this.getData();
			}

		}
	}
</script>

<style lang="scss">
	.page {
		background-color: $grayf5;
	}

	.item {
		display: flex;
		flex-direction: column;
		background-color: white;
		border-radius: 8rpx;
		margin: 10rpx 20rpx;
		padding-bottom: 10rpx;
	}

	.title {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		color: $black33;
		margin-left: 20rpx;
	}

	.text-warn {
		font-size: 24rpx;
		color: $rede9;
		margin-right: 20rpx;
	}

	.text-warn-orange {
		color: $yellowffc;
	}

	.btn-detail {
		width: 180rpx;
		height: 60rpx;
		border-radius: 50rpx;
		color: white;
		text-align: center;
		background-color: $blue15;
		font-size: 26rpx;
		line-height: 60rpx;
		margin: 10rpx 20rpx 10rpx;
		align-self: flex-end;
	}
</style>
